package com.nervenets.web.hibernate.domain.knowledge;

import com.nervenets.web.hibernate.DomainObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Knowledge extends DomainObject {
    @ApiModelProperty(value = "团队ID")
    private long managerId;
    @ApiModelProperty(value = "团队成员ID")
    private long userId;
    @ManyToMany
    @JoinTable(
            name = "tags_of_knowledge",
            joinColumns = {@JoinColumn(name = "knowledge_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "tags_id", referencedColumnName = "id")}
    )
    @ApiModelProperty(value = "相关标签")
    private Set<Tags> tags = new HashSet<>();
    @ApiModelProperty(value = "标题")
    private String title;
    @ApiModelProperty(value = "富文本内容")
    @Column(columnDefinition = "text")
    private String content;
    @ApiModelProperty(value = "附件列表")
    @org.hibernate.annotations.Type(type = "com.nervenets.web.adapter.jsonType.AttachmentArrayJson")
    @Column(columnDefinition = "text")
    private List<Attachment> attachments = new ArrayList<>();
    private int visit;
    private String qrCode;
}
